From 7d5eee4f2c1424142790c944c8e083d13a295a37 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 25 Nov 2009 14:06:17 +0000 Subject: [PATCH] cpuidle: Add decaying history logic to menu idle predictor this patch is ported from linux upstream git commit 816bb611e41be29b476dc16f6297eb551bf4d747 the original description is: " Add decaying history of predicted idle time, instead of using the last early wakeup. This logic helps menu governor do better job of predicting idle time. With this change, we also measured noticable (~8%) power savings on a DP server system with CPUs supporting deep C states, when system was lightly loaded. There was no change to power or perf on other load conditions. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown " In Xen environment, we also observe this patch reduce the idle power fluctuation. In one DP server, when system is purely idle, the watts stdev/average reduce from 6% to 2%. it is helpful for idle power measurement accuracy. There is no performance and power change when system is loaded. Signed-off-by: Yu Ke --- xen/arch/x86/acpi/cpuidle_menu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/acpi/cpuidle_menu.c b/xen/arch/x86/acpi/cpuidle_menu.c index 4b284219fe..e2c350962c 100644 --- a/xen/arch/x86/acpi/cpuidle_menu.c +++ b/xen/arch/x86/acpi/cpuidle_menu.c @@ -32,6 +32,7 @@ #include #define BREAK_FUZZ 4 /* 4 us */ +#define PRED_HISTORY_PCT 50 #define USEC_PER_SEC 1000000 struct menu_device @@ -39,6 +40,7 @@ struct menu_device int last_state_idx; unsigned int expected_us; unsigned int predicted_us; + unsigned int current_predicted_us; unsigned int last_measured_us; unsigned int elapsed_us; }; @@ -64,6 +66,12 @@ static int menu_select(struct acpi_processor_power *power) /* determine the expected residency time */ data->expected_us = get_sleep_length_us(); + /* Recalculate predicted_us based on prediction_history_pct */ + data->predicted_us *= PRED_HISTORY_PCT; + data->predicted_us += (100 - PRED_HISTORY_PCT) * + data->current_predicted_us; + data->predicted_us /= 100; + /* find the deepest idle state that satisfies our constraints */ for ( i = 2; i < power->count; i++ ) { @@ -94,7 +102,7 @@ static void menu_reflect(struct acpi_processor_power *power) measured_us = data->elapsed_us <= measured_us ? measured_us : -1; /* Predict time remaining until next break event */ - data->predicted_us = max(measured_us, data->last_measured_us); + data->current_predicted_us = max(measured_us, data->last_measured_us); /* Distinguish between expected & non-expected events */ if ( last_residency + BREAK_FUZZ -- 2.30.2